﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Kindohm.Life.Library
{
    public struct Point
    {
        public int X;
        public int Y;

        public Point(int xPosition, int yPosition)
        {
            this.X = xPosition;
            this.Y = yPosition;
        }

        public override string ToString()
        {
            return string.Format("{0}{1},{2}{3}", "{", this.X.ToString(), this.Y.ToString(), "}");
        }

        public static Point operator -(Point point1, Point point2)
        {
            int difX = point2.X - point1.X;
            int difY = point2.Y - point2.Y;
            return new Point(difX, difY);        
        }

        public static int Distance(Point p1, Point p2)
        {
            int x = p2.X - p1.X;
            x = x * x;
            int y = p2.Y - p1.Y;
            y = y * y;

            double sum = Convert.ToDouble(x + y);
            double root = Math.Sqrt(sum);
            return Convert.ToInt32(root); 
        }

    }
}
